import {postAction, putAction} from '@/api/manage'

export const HandleClDicOk = {
    data() {
        return {
            url: {
                putClDicInfo: "/my/cl_dic/putClDicInfo",
                addClDicInfo: "/my/cl_dic/addClDicInfo",
                putHwDicInfo: "/my/hw_dic/putHwDicInfo",
                addHwDicInfo: "/my/hw_dic/addHwDicInfo",
                putQzDicInfo: "/my/qz_dic/putQzDicInfo",
                addQzDicInfo: "/my/qz_dic/addQzDicInfo",
                putUserDicInfo: "/my/user_dic/putUserDicInfo",
                addUserDicInfo: "/my/user_dic/addUserDicInfo",
            }
        }
    },
    methods: {
        //增加一个车辆类型字典
        handleAddClccOk() {
            this.addClcc = false;
            var json = {
                dic:"clcc",
                data:{
                    clCcbz:0,
                    clCc:""
                }
            };
            this.postClDicAction(json)
        },
        handleAddClcpysOk() {
            this.addClcpys = false;
            var json = {
                dic:"clcpys",
                data:{
                    clCpysbz:0,
                    clCpys:""
                }
            };
            this.postClDicAction(json)
        },
        handleAddCllxOk() {
            this.addCllx = false;
            var json = {
                dic:"cllx",
                data:{
                    clLxbz:"",
                    clLx:""
                }
            };
            this.postClDicAction(json)
        },
        handleAddClppOk() {
            this.addClpp = false;
            var json = {
                dic:"clpp",
                data:{
                    clPpbz:"",
                    clPp:""
                }
            };
            this.postClDicAction(json)
        },
        handleAddClzzOk() {
            this.addClzz = false;
            var json = {
                dic:"clzz",
                data:{
                    clZzbz:"",
                    clZz:""
                }
            };
            this.postClDicAction(json)
        },
        postClDicAction(json){
            postAction(this.url.addClDicInfo, json).then((res) => {
                if (res.success) {
                    this.$message.success("添加成功");
                } else {
                    this.$message.warning(res.message)
                }
            })
        },

        //修改一个车辆类型字典
        handleMdfClccOk() {
            this.mdfClcc = false;
            var json = {
                dic:"clcc",
                data:{
                    clccId:0,
                    clCcbz:0,
                    clCc:""
                }
            };
            this.putClDicAction(json)
        },
        handleMdfClcpysOk() {
            this.mdfClcpys = false;
            var json = {
                dic:"clcpys",
                data:{
                    cpysId:0,
                    clCpysbz:0,
                    clCpys:""
                }
            };
            this.putClDicAction(json)
        },
        handleMdfCllxOk() {
            this.mdfCllx = false;
            var json = {
                dic:"cllx",
                data:{
                    cllxId:0,
                    clLxbz:0,
                    clLx:""
                }
            };
            this.putClDicAction(json)
        },
        handleMdfClppOk() {
            this.mdfClpp = false;
            var json = {
                dic:"clpp",
                data:{
                    clppId:0,
                    clPpbz:0,
                    clPp:""
                }
            };
            this.putClDicAction(json)
        },
        handleMdfClzzOk() {
            this.mdfClzz = false;
            var json = {
                dic:"clzz",
                data:{
                    clzzId:0,
                    clZzbz:0,
                    clZz:""
                }
            };
            this.putClDicAction(json)
        },
        putClDicAction(json){
            putAction(this.url.putClDicInfo, json).then((res) => {
                if (res.success) {
                    this.$message.success("修改成功");
                } else {
                    this.$message.warning(res.message)
                }
            })
        },
    }
}